#region File Description
//-----------------------------------------------------------------------------
// PauseMenuScreen.cs
//
// Microsoft XNA Community Game Platform
// Copyright (C) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
#endregion

#region Using Statements
using Microsoft.Xna.Framework;
#endregion

namespace TestGame {
    /// <summary>
    /// The pause menu comes up over the top of the game,
    /// giving the player options to resume or quit.
    /// </summary>
    class PauseMenuScreen : MenuScreen {
        #region Initialization

        /// <summary>
        /// Constructor.
        /// </summary>
        public PauseMenuScreen() : base("Paused") {
            // Create our menu entries.
            MenuEntry resumeGameEntry = new MenuEntry("Resume Game");
            MenuEntry optionsEntry = new MenuEntry("Options");
            MenuEntry quitGameEntry = new MenuEntry("Quit Game");

            // Hook up menu event handlers.
            resumeGameEntry.Selected += OnCancel;
            optionsEntry.Selected += OnOptionsSelected;
            quitGameEntry.Selected += QuitGameMenuEntrySelected;

            // Add entries to the menu.
            MenuEntries.Add(resumeGameEntry);
            MenuEntries.Add(optionsEntry);
            MenuEntries.Add(quitGameEntry);
        }

        #endregion

        #region Event Handlers

        /// <summary>
        /// Event Handler for when Options menu entry is selected.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnOptionsSelected(object sender, PlayerIndexEventArgs e) {
            ScreenManager.AddScreen(new OptionsMenuScreen(), ControllingPlayer);
        }

        /// <summary>
        /// Event handler for when the Quit Game menu entry is selected.
        /// </summary>
        void QuitGameMenuEntrySelected(object sender, PlayerIndexEventArgs e) {
            const string message = "Are you sure you want to quit?";

            ConfirmMessageBoxScreen confirm = new ConfirmMessageBoxScreen(message);

            confirm.Accepted += QuitAccepted;

            ScreenManager.AddScreen(confirm, ControllingPlayer);
        }


        /// <summary>
        /// Event handler for when the ConfirmMessageBox has been confirmed.
        /// </summary>
        void QuitAccepted(object sender, PlayerIndexEventArgs e) {
            LoadingScreen.Load(ScreenManager, false, null, new BackgroundScreen(),
                                                           new MainMenuScreen());
        }

        #endregion
    }
}
